﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data.Linq.Mapping;

namespace Common
{
    [Table]
    public class LoaiHangHoa
    {
        [Column(IsPrimaryKey=true, IsDbGenerated=true, DbType="Int NOT NULL IDENTITY", AutoSync = AutoSync.OnInsert)]
        public int iLoaiHangHoa_ID { get; set; }
        [Column]
        public string sTenLoai { get; set; }
        [Column]
        public string sHinhDaiDien { get; set; }
        [Column]
        public string sMoTa { get; set; }
        [Column]
        public bool bTrangChu { get; set; }
        [Column]
        public bool bQuanLy { get; set; }
        
        public LoaiHangHoa()
        {

        }
        public LoaiHangHoa(SqlDataReader reader)
        {
            if (reader != null && !reader.IsClosed && reader.Read())
            {
                //if(!reader.IsDBNull(reader.GetOrdinal("iDonViTinh_ID"));
                if (DAHelper.HasColumn(reader, "iLoaiHangHoa_ID")) this.iLoaiHangHoa_ID = Convert.ToInt32(reader["iLoaiHangHoa_ID"]);
                if (DAHelper.HasColumn(reader, "sTenLoai")) this.sTenLoai = reader["sTenLoai"].ToString();
                if (DAHelper.HasColumn(reader, "sHinhDaiDien")) this.sHinhDaiDien = reader["sHinhDaiDien"].ToString();
                if (DAHelper.HasColumn(reader, "sMoTa")) this.sMoTa = reader["sMoTa"].ToString();
                if (DAHelper.HasColumn(reader, "bTrangChu")) this.bTrangChu = Convert.ToBoolean(reader["bTrangChu"]);
                if (DAHelper.HasColumn(reader, "bQuanLy")) this.bQuanLy = Convert.ToBoolean(reader["bQuanLy"]);

            }
            reader.Close();
            reader.Dispose();
        }
    }
}
